<template>
  <div id="app">
	  <router-view></router-view>
  </div>
</template>

<script>
  //导入需要的组建，可以导入多个组建
  import NetWorking from '../../utils/networking'

  export default {
    name: 'app',
    components: {
      //将需要的组建注册进来
    },
	  beforeCreate (){
		  let _this = this
		 
		  this.$store.commit('FETCH_TOKEN')
		  this.$store.commit('FETCH_LAST_LOGIN_AS')
		  if(this.$store.state.user.token != null) {
			  NetWorking.doGet(
				  'auth/checkToken',
				  null,
				  null,
			  ).then(
				  response => {
					  let rs = response.data
					  if (rs.error_code == 0) {
						  if(_this.$store.state.user.lastLoginAs == 'teacher'){
							  location.replace('/mavinTeacher')
						  }else if(_this.$store.state.user.lastLoginAs == 'consultant'){
							  location.replace('/mavinSales')
						  }else{
							  _this.$store.commit('DELETE_TOKEN')
							  _this.$store.commit('DELETE_LAST_LOGIN_AS')
							  //location.replace('/login')
						  }
					  } else {
						  //router.push({ name: 'openid', params: { openid: 123 }})
					  }
				  }
			  )
		  }else{
			  //vue.$router.push('/')
			  //vue.$router.go(0)
			  //vue.$router.push({ name: 'loginopenid', params: { openid: 123 }})
		  }
	  }
  }
</script>

<style scoped>

</style>
